<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd">
<html>
<head>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<title>Exported from Notepad++</title>
<style type="text/css">
span {
	font-family: 'Courier New';
	font-size: 10pt;
	color: #000000;
}
.sc0 {
}
.sc2 {
	font-style: italic;
	color: #0000FF;
}
.sc4 {
	color: #8000FF;
}
.sc5 {
	font-weight: bold;
	font-style: italic;
	color: #0000FF;
}
.sc6 {
	font-weight: bold;
	color: #008000;
}
.sc8 {
	font-weight: bold;
	font-style: italic;
	color: #008000;
}
.sc10 {
	font-weight: bold;
	color: #0080FF;
}
.sc11 {
}
.sc14 {
	color: #8080FF;
}
</style>
</head>
<body>
<div style="float: left; white-space: pre; line-height: 1; background: #FFFFFF; "><span class="sc2">// ========================================================= //</span><span class="sc0">
</span><span class="sc2">// ================== FREQ.BPI : BEBOP 1.0 ================= //</span><span class="sc0">
</span><span class="sc2">// ========================================================= //</span><span class="sc0">

</span><span class="sc2">// compile with bopbuild</span><span class="sc0">
</span><span class="sc2">// call with -ni not to wait for '\n' on stdin</span><span class="sc0">

</span><span class="sc2">// freq.bpi permet de regler la frequence d'une simulation.</span><span class="sc0">

</span><span class="sc10">#</span><span class="sc5">source</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc14">"ocaml"</span><span class="sc0">

</span><span class="sc2">// On veut pouvoir regler dynamiquement l'application, en precisant la frequence.</span><span class="sc0">
</span><span class="sc10">#</span><span class="sc5">sysargv</span><span class="sc0"> </span><span class="sc11">f</span><span class="sc0">

</span><span class="sc10">#</span><span class="sc6">init</span><span class="sc0"> </span><span class="sc10">%{</span><span class="sc0">
    </span><span class="sc10">(</span><span class="sc11">*</span><span class="sc0"> 
    </span><span class="sc8">Dans</span><span class="sc0"> </span><span class="sc11">la</span><span class="sc0"> </span><span class="sc8">Bplib</span><span class="sc0"> </span><span class="sc10">(</span><span class="sc11">ajoutée</span><span class="sc0"> </span><span class="sc11">lors</span><span class="sc0"> </span><span class="sc11">de</span><span class="sc0"> </span><span class="sc11">l'édition</span><span class="sc0"> </span><span class="sc11">de</span><span class="sc0"> </span><span class="sc11">lien</span><span class="sc0"> </span><span class="sc11">par</span><span class="sc0"> </span><span class="sc11">le</span><span class="sc0"> </span><span class="sc8">BEBOPMakefile</span><span class="sc0">
    </span><span class="sc11">il</span><span class="sc0"> </span><span class="sc11">y</span><span class="sc0"> </span><span class="sc11">a</span><span class="sc0"> </span><span class="sc11">une</span><span class="sc0"> </span><span class="sc11">classe</span><span class="sc0"> </span><span class="sc11">sleeper</span><span class="sc0"> </span><span class="sc11">avec</span><span class="sc0"> </span><span class="sc11">une</span><span class="sc0"> </span><span class="sc11">option</span><span class="sc0"> </span><span class="sc11">pour</span><span class="sc0"> </span><span class="sc11">faire</span><span class="sc0"> </span><span class="sc11">comme</span><span class="sc0"> </span><span class="sc11">si</span><span class="sc0"> </span><span class="sc11">l'execution</span><span class="sc0">
    </span><span class="sc11">avait</span><span class="sc0"> </span><span class="sc11">commencée</span><span class="sc0"> </span><span class="sc11">le</span><span class="sc0"> </span><span class="sc11">jour</span><span class="sc0"> </span><span class="sc11">meme</span><span class="sc0"> </span><span class="sc11">mais</span><span class="sc0"> </span><span class="sc11">à</span><span class="sc0"> </span><span class="sc11">minuit</span><span class="sc10">.</span><span class="sc0"> 
    </span><span class="sc8">Cette</span><span class="sc0"> </span><span class="sc11">option</span><span class="sc0"> </span><span class="sc11">doit</span><span class="sc0"> </span><span class="sc11">aussi</span><span class="sc0"> </span><span class="sc11">etre</span><span class="sc0"> </span><span class="sc11">dynamique</span><span class="sc10">.</span><span class="sc0">
    </span><span class="sc11">*</span><span class="sc10">)</span><span class="sc0">
    
    </span><span class="sc10">(</span><span class="sc11">*</span><span class="sc0"> </span><span class="sc8">Pour</span><span class="sc0"> </span><span class="sc11">des</span><span class="sc0"> </span><span class="sc11">options</span><span class="sc0"> </span><span class="sc11">d'activation</span><span class="sc10">,</span><span class="sc0"> </span><span class="sc11">on</span><span class="sc0"> </span><span class="sc11">utilise</span><span class="sc0"> </span><span class="sc11">args</span><span class="sc0"> </span><span class="sc11">qui</span><span class="sc0"> </span><span class="sc11">est</span><span class="sc0"> </span><span class="sc11">la</span><span class="sc0"> </span><span class="sc11">liste</span><span class="sc0"> </span><span class="sc11">des</span><span class="sc0"> </span><span class="sc11">arguments</span><span class="sc0"> </span><span class="sc11">systeme</span><span class="sc0"> </span><span class="sc11">*</span><span class="sc10">)</span><span class="sc0">
    </span><span class="sc11">let</span><span class="sc0"> </span><span class="sc11">minuit</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc8">List</span><span class="sc10">.</span><span class="sc11">mem</span><span class="sc0"> </span><span class="sc14">"-m"</span><span class="sc0"> </span><span class="sc11">args</span><span class="sc10">;;</span><span class="sc0">

    </span><span class="sc10">(</span><span class="sc11">*</span><span class="sc0"> </span><span class="sc8">On</span><span class="sc0"> </span><span class="sc11">peut</span><span class="sc0"> </span><span class="sc11">instancier</span><span class="sc0"> </span><span class="sc11">l'objet</span><span class="sc0"> </span><span class="sc11">*</span><span class="sc10">)</span><span class="sc0">
    </span><span class="sc11">let</span><span class="sc0"> </span><span class="sc11">pause</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc11">new</span><span class="sc0"> </span><span class="sc8">Bplib</span><span class="sc10">.</span><span class="sc11">sleeper</span><span class="sc0"> </span><span class="sc10">(</span><span class="sc4">1</span><span class="sc10">.</span><span class="sc11">/</span><span class="sc10">.(</span><span class="sc11">float_of_int</span><span class="sc0"> </span><span class="sc11">_f</span><span class="sc10">))</span><span class="sc0"> </span><span class="sc11">minuit</span><span class="sc10">;;</span><span class="sc0">
</span><span class="sc10">}%</span><span class="sc0">

</span><span class="sc10">#</span><span class="sc5">input</span><span class="sc0"> </span><span class="sc11">myinput</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc6">clock</span><span class="sc0">
</span><span class="sc10">#</span><span class="sc5">where</span><span class="sc0">
    </span><span class="sc2">// On cree une sortie clock, qui appelle la methode sleep a chaque cycle.</span><span class="sc0">
    </span><span class="sc6">clock</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc5">unitfun</span><span class="sc10">(</span><span class="sc14">"fun () -&gt; (pause#sleep; true)"</span><span class="sc10">);</span><span class="sc0">
</span><span class="sc10">#</span><span class="sc5">end</span><span class="sc0"> </span><span class="sc5">where</span><span class="sc10">;</span><span class="sc0">

</span></div></body>
</html>
